﻿@{
    Layout = null;
}

<style>
    .phone-num{
        display:flex;
        align-items: center;
        background-color: white;
        margin-bottom: 10px;
        border-radius: 3px;
    }

    .phone-num>span{
        padding: 5px;
        border: 1px solid #eee;
        border-right: none;
        border-top-left-radius: 3px;
        border-bottom-left-radius: 3px;
    }

    .phone-num > input {
        width: 90%;
        height: 34px;
        line-height: 34px;
        border-style: none;
        border-radius: 3px;
        border: 1px solid #eee;
        padding-left: 5px;
    }

    .sure{
        display:block;
        background-color: rgb(255,204,0);
        text-align: center;
        height: 35px;
        color: rgb(118,52,1);
        line-height: 35px;
        text-decoration: none;
        border-radius: 4px;
        margin: 20px auto;
        cursor:pointer;
    }

    .sure:hover {
        text-decoration: none;
        color: rgb(118,52,1);
    }
</style>

<div class="phone-num">
    <span>+86</span>
    <input style="flex:1" id="phoneNum" type="text" placeholder="请填写手机号码" autofocus="">
</div>
<div class="phone-num">
    <input style="width:60%;" type="text" placeholder="请输入短信验证码" autofocus="" id="SMS">
    <input type="button" id="GetSMS" style="color: #826A50;width:40%;" onclick="GetSMS()" value="获取验证码">
</div>
 
<script>
    var num = /^1[1-9]\d{9}$/;
    var sms;
    function GetSMS() {
        var that = this;
        var phone = $("#phoneNum").val();
        if (!num.test(phone)) {
            alert('请输入正确的手机号码');
            return;
        }
        $(this).attr('disabled', 'disabled');
        var Num = 60;
        time();
        function time() {
            Num--;
            if (Num > 0) {
             
                $("#GetSMS").val(Num + '秒后重发');
                $("#GetSMS").attr('disabled', 'disabled');
                setTimeout(function () {
                    time();
                }, 1000);
            }
            else {
               
                $("#GetSMS").val('获取验证码');
                $("#GetSMS").removeAttr('disabled');
            }
        }

        $.ajax({
            url: "/ConfigManager/GetSMS",
            data: {
                phoneNum: $("#phoneNum").val(),
                key: $("#Appkey").val(),
                code: $("#ModelCode").val()
            },
            success: function (reulstSms) {
                sms = reulstSms;

            }
        });
    }

    function VerifySms() {
        if ($("#SMS").val() == sms) {
            $.MGJ.SMSApi.Ajax_Save();

        }
        else {
            alert("请检查验证码!");
        }
    }

</script>